package com.heima.admin.controller;


import com.heima.admin.service.IAdUserService;
import com.heima.model.admin.dtos.AdminLoginDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 后端管理平台登录接口
 */
@RestController
@Slf4j
@Api(tags = "登录相关接口")
public class AdUserLoginController {
    @Autowired
    private IAdUserService adUserService;
    @PostMapping("/login/in")
    @ApiOperation(value = "登录接口")
    public ResponseResult login(@RequestBody AdminLoginDto dto){
        if (ObjectUtils.isEmpty(dto)){
            ResponseResult.errorResult(AppHttpCodeEnum.DATA_NOT_EXIST);
        }
        return adUserService.login(dto);
    }
}
